home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / tn0607.zip / TN06007.TXT
Text File  |  1992-06-05  |  11KB  |  333 lines

  1.  
  2. ────────────────────────────────────────────────────────────────────────────────
  3. Innovative Data Concepts, Inc.                 Technical Information Note
  4. TesSeRact Development Tools
  5. ────────────────────────────────────────────────────────────────────────────────
  6. Using Compiler Switches with TCXL
  7. TN-9206-007                                                  June 5, 1992
  8. ────────────────────────────────────────────────────────────────────────────────
  9.  
  10. In this  Tech Note,  we will  explain the compiler switches that we use to build
  11. TCXL-DOS libraries.   Most  are applicable  and  recommended  for  your  use  in
  12. compiling your  applications.  (If you use MAKEGEN.BAT and GEN.SMF to build your
  13. TCXL programs,  as described in Tech Note TN-9204-004, you will already be using
  14. these switches, but may wish to understand them better anyway.)
  15.  
  16. Turbo C/C++ & Borland C++
  17.  
  18. Compiling for debugging:
  19.  
  20.       -c -m<model> -DTCXLDBG -v -K -w -d -N- -k- -IINC -I. -DTCXL -O -Z
  21.  
  22. Compiling for production:
  23.  
  24.  
  25.  
  26.   -c -m<model> -K -w -d -N- -k- -IINC -I. -DTCXL -O -Z
  27.  
  28. Explanation:
  29.  
  30.       Switch          Meaning
  31.       ======          =======
  32.  
  33.       -c              Compile without linking
  34.  
  35.       -m<model>       Memory model, where <model> is s, c, m, l, or h
  36.  
  37.       -DTCXLDBG       Preprocessor definition to activate TCXL debugging
  38.                       code (debugging only)
  39.  
  40.       -v              Compile for debugger (debugging only)
  41.  
  42.       -K              Treat characters as unsigned by default
  43.  
  44.       -w              All warnings on
  45.  
  46.       -d              Merge duplicate strings
  47.  
  48.       -N-             Don't check for stack overflow
  49.  
  50.       -k-             Don't use standard stack frame
  51.  
  52.       -IINC           Look for header files in the INC directories
  53.                       (only valid if you're working in the TCXL root
  54.                       directory)
  55.  
  56.       -I.             Look for header files in the current directory
  57.  
  58.       -DTCXL          Preprocessor definition used for conditional
  59.  
  60.  
  61.  
  62. TN-9206-007                                                        Page 2
  63.                       compilation within the library
  64.  
  65.       -O              Optimize jumps
  66.  
  67.       -Z              Optimize register usage
  68.  
  69.  
  70.  
  71.  
  72. Notes:
  73.  
  74.   1. The '-w'  setting is highly recommended.  In general, we recommend that you
  75.      use the highest levels of warnings that your compiler can produce.
  76.  
  77.   2. The '-d'  setting is  safe to  use so  long as  you don't attempt to modify
  78.      static strings within your program.
  79.  
  80.   3. The '-N-'  and '-k-'  settings are used because enabling these options adds
  81.      bulk to your program.  If you want to allow these settings to active (which
  82.      is the default), it's up to you -- just don't compile the library that way!
  83.  
  84.   4. The  optimization setting  we use  here ('-O'  and '-Z') represent settings
  85.      that in  our experience we have found to be generally "safe".  You may find
  86.      that other optimizations settings work just fine for your applications, but
  87.      we  recommend  that  you  stick  with  these  setting  when  building  TCXL
  88.      libraries, since optimizers have been known to break existing code!
  89.  
  90.   5. When compiling a huge-model TCXL library, you must use the settings
  91.  
  92.       -zR_DATA -zTDATA
  93.  
  94.      in addition  to '-mh'.  Without going into all the details, this is part of
  95.      a scheme  that we  use to  allow assembler modules to link correctly with C
  96.      modules in huge model.
  97.  
  98.  
  99.  
  100. Microsoft 5.1, 6.x, and 7.0, Quick C
  101.  
  102. Compiling for debugging:
  103.  
  104.       /c /A<model> /Od /DTCXLDBG /Zi /J /Gs /W[3 | 4] /IINC /I. /DTCXL /Zp1
  105.  
  106. Compiling for production:
  107.  
  108.       /c /A<model> /O[ils | x] /J /Gs /W[3 | 4] /IINC /I. /DTCXL /Zp1
  109.  
  110. Explanation:
  111.  
  112.       Switch          Meaning
  113.       ======          =======
  114.  
  115.       /c              Compile without linking
  116.  
  117.  
  118.  
  119. TN-9206-007                                                        Page 3
  120.  
  121.       /A<model>       Memory model, where <model> is s, c, m, l, or h
  122.  
  123.       /Od             No optimization (debugging only)
  124.  
  125.       /Oils           Optimization: use intrinsic functions, loop
  126.                       optimization, and optimize for speed (MSC 5.1 and
  127.                       6.0x, non-debugging only)
  128.  
  129.       /Ox             Full optimization (MSC 7.0, non-debugging only)
  130.  
  131.       /DTCXLDBG       Preprocessor definition to activate TCXL debugging
  132.                       code (debugging only)
  133.  
  134.       /Zi             Compile for debugger (debugging only)
  135.  
  136.       /J              Treat characters as unsigned by default
  137.  
  138.       /Gs             Turn off stack checking
  139.  
  140.       /IINC           Look for header files in the INC directories
  141.                       (only valid if you're working in the TCXL root
  142.                       directory)
  143.  
  144.       /I.             Look for header files in the current directory
  145.  
  146.       /DTCXL          Preprocessor definition used for conditional
  147.                       compilation within the library
  148.  
  149.       /Zp1            Pack structures on one 1-byte boundary (i.e., byte        
  150.       alignment)
  151.  
  152. Notes:
  153.  
  154.   1. The '/Wn'  setting establishes  the compiler's  warning.   For MSC  5.1 the
  155.      highest setting  is 3;  for MSC  6.x and  7.0  4  is  the  highest  setting
  156.      (although we use /W3 for MSC 7.0).
  157.  
  158.   2. We have had problems with buggy optimization in MSC 5.1 and 6.x, forcing us
  159.      to limit optimizations to '/Oils'.  Within certain library modules compiled
  160.      with MSC  6.x, in fact, we even have to disable loop optimizations.  In MSC
  161.      7.0, however,  we have  found that  the optimizations produce more reliable
  162.      code, and therefore use full optimization.
  163.  
  164.   3. We disable stack checking with the '/Gs' switch because it adds extra code.
  165.  
  166.   4. The  '/Zp1' setting  is very  important for  TCXL library  code.  Many data
  167.      structures in  the library  are accessed  by both  C and  assembler, so the
  168.      compiler must  not be  allowed  to  pad  them.    Instead,  all  TCXL  data
  169.      structures  are   carefully  hand-constructed  to  align  members  to  word
  170.      boundaries.
  171.  
  172.  
  173.  
  174. TN-9206-007                                                        Page 4
  175. Zortech C/C++
  176.  
  177. Compiling for debugging:
  178.  
  179.       -c -m<model> -DTCXLDBG -g -o-all -J -Ju -w- -r -a1 -IINC -I. -s- -S-
  180.       -v0 -DTCXL
  181.  
  182. Compiling for production:
  183.  
  184.       -c -m<model> -o-liv -o-loop -J -Ju -w- -r -a1 -IINC -I. -s- -S- -v0
  185.       -DTCXL
  186.  
  187. Explanation:
  188.  
  189.       Switch          Meaning
  190.       ======          =======
  191.  
  192.       -c              Compile without linking
  193.  
  194.       -m<model>       Memory model, where <model> is si, ci, mi, li, or hi
  195.  
  196.       -DTCXLDBG       Preprocessor definition to activate TCXL debugging
  197.                       code (debugging only)
  198.  
  199.       -g              Compiler for debugger (debugging only)
  200.  
  201.       -o-all          No optimization (debugging only)
  202.  
  203.       -o-liv          Loop invariant optimization (non-debugging only)
  204.  
  205.       -o-loop         Multi-pass optimization (non-debugging only)
  206.  
  207.       -J              Use unsigned chars
  208.  
  209.       -Ju             Make char == unsigned char (for C++ type checking)
  210.  
  211.       -w-             Turn on all compiler warnings
  212.  
  213.       -r              Enforce strict function prototyping
  214.  
  215.       -a1             Use byte alignment
  216.  
  217.       -s-             Disable stack checking
  218.  
  219.       -S-             Don't use standard stack frame
  220.  
  221.       -v0             Compile quietly (no unnecessary messages)
  222.  
  223.       -IINC           Look for header files in the INC directories
  224.                       (only valid if you're working in the TCXL root
  225.                       directory)
  226.  
  227.       -I.             Look for header files in the current directory
  228.  
  229.  
  230.  
  231. TN-9206-007                                                        Page 5
  232.  
  233.       -DTCXL          Preprocessor definition used for conditional
  234.                       compilation within the library
  235.  
  236.  
  237. Notes:
  238.  
  239.   1. Comments made  for the  previous compilers  regarding byte alignment, stack
  240.      checking, and stack frames apply here as well.
  241.  
  242.  
  243.  
  244. Watcom C
  245.  
  246. Compiling for debugging:
  247.  
  248.       /c /m<model> /dTCXLDBG /d2 /i=INC -i=. /w4 /zp1 /zq /dTCXL
  249.  
  250. Compiling for production:
  251.  
  252.       /c /m<model> /oaxt /i=INC -i=. /w4 /zp1 /zq /dTCXL
  253.  
  254. Explanation:
  255.  
  256.       Switch          Meaning
  257.       ======          =======
  258.  
  259.       /c              Compile without linking
  260.  
  261.       /m<model>       Memory model, where <model> is s, c, m, l, or h
  262.  
  263.       /dTCXLDBG       Preprocessor definition to activate TCXL debugging
  264.                       code (debugging only)
  265.  
  266.       /d2             Compiler for debugger (debugging only)
  267.  
  268.       /oaxt           Full optimization with aliasing, optimized for speed      
  269.       (non-debugging only)
  270.  
  271.       /i=INC          Look for header files in the INC directories
  272.                       (only valid if you're working in the TCXL root
  273.                       directory)
  274.  
  275.       -i=.            Look for header files in the current directory
  276.  
  277.       -w4             Turn on all compiler warnings
  278.  
  279.       -zp1            Byte alignment
  280.  
  281.       /zq             Compile quietly (no unnecessary messages)
  282.  
  283. Notes:
  284.  
  285.  
  286.  
  287. TN-9206-007                                                        Page 6
  288.   1. Regarding byte alignment, see the notes for the Microsoft compilers.
  289.  
  290.  
  291.  
  292. JPI TopSpeed C/C++
  293.  
  294. Compiling for debugging:
  295.  
  296.       /m<model> /ox- /dTCXLDBG /v2 /b /j+ /w+ /zq /m /dTCXL
  297.  
  298. Compiling for production:
  299.  
  300.       /m<model> /j+ /w+ /zq /m /dTCXL
  301.  
  302. Explanation:
  303.  
  304.       Switch          Meaning
  305.       ======          =======
  306.  
  307.       /m<model>       Memory model, where <model> is s, c, m, l, or x
  308.  
  309.       /ox-            No optimization (debugging only)
  310.  
  311.       /dTCXLDBG       Preprocessor definition to activate TCXL debugging
  312.                       code (debugging only)
  313.  
  314.       /v2             Compile for debugger (debugging only)
  315.  
  316.       /b              Put line number information in .OBJ files (debugging      
  317.       only)
  318.  
  319.       /j+             Make chars unsigned
  320.  
  321.       /w+             Turn on all compiler warnings
  322.  
  323.       /zq             Compile quietly (no unnecessary messages)
  324.  
  325.       /m              Make (see below)
  326.  
  327. Notes:
  328.  
  329.   1. Unlike the other compilers, TopSpeed C uses full optimization by default.
  330.  
  331.   2. The '/m'  (make) switch  is used  to tell the compiler to use JPI's project
  332.      system.   Of course,  if you want to compile your own application, you must
  333.      make you own project file.